package com.pnk087.hr.domain;

import javax.persistence.*;

/**
 * User: khanh
 * Date: 6/22/11 2:49 PM
 */
@Entity
@Table(name = "users")
@NamedQueries(
        {@NamedQuery(name = "User.findActiveUser", query = "select u from User u where u.active=true"),
        @NamedQuery(name = "User.findByUsername", query = "select u from User u where u.active=true and u.username = :username")})
public class User implements Persistable {
   private static final long serialVersionUID = -6819407799278796285L;

   @Id
   @GeneratedValue(strategy = GenerationType.TABLE, generator = "gen_user")
   @TableGenerator(name = "gen_user", table = "sequence_list", pkColumnName = "name", valueColumnName = "next_value",
           pkColumnValue = "user", allocationSize = 1, initialValue = 3000)
   @Column(name = "user_id")
   private Long id;

   @Version
   @Column(name = "version_no")
   private Long version = 0L;

   @Column(name = "username")
   private String username;

   @Column(name = "first_name")
   private String firstName;

   @Column(name = "last_name")
   private String lastName;

   @Column(name = "password")
   private String password;

   @Column(name = "email")
   private String email;

   @Column(name = "phone")
   private String phone;

   @Column(name = "mobile")
   private String mobile;

   @Column(name = "active")
   private Boolean active;

   @OneToOne(cascade = CascadeType.ALL)
   @JoinColumn(name = "address_id")
   private Address address;

   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public String getUsername() {
      return username;
   }

   public void setUsername(String username) {
      this.username = username;
   }

   public String getFirstName() {
      return firstName;
   }

   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }

   public String getLastName() {
      return lastName;
   }

   public void setLastName(String lastName) {
      this.lastName = lastName;
   }

   public String getPassword() {
      return password;
   }

   public void setPassword(String password) {
      this.password = password;
   }

   public String getEmail() {
      return email;
   }

   public void setEmail(String email) {
      this.email = email;
   }

   public String getPhone() {
      return phone;
   }

   public void setPhone(String phone) {
      this.phone = phone;
   }

   public String getMobile() {
      return mobile;
   }

   public void setMobile(String mobile) {
      this.mobile = mobile;
   }

   public Boolean getActive() {
      return active;
   }

   public void setActive(Boolean active) {
      this.active = active;
   }
}
